home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / INSTALL.AML < prev    next >
Text File  |  1996-07-17  |  9KB  |  343 lines

  1. //--------------------------------------------------------------------
  2. // The Aurora Editor v3.0, Copyright (C) 1993-1996 nuText Systems
  3. //
  4. // INSTALL.AML
  5. // Installation Macro
  6. //
  7. // This macro installs all Aurora files to a user-specified path, and
  8. // also prompts the user for an editor style and color palette to use.
  9. //--------------------------------------------------------------------
  10.  
  11. // compile time macros and function definitions
  12. include bootpath "define.aml"
  13.  
  14. // main window colors
  15. constant inst_border_color   = color white on gray
  16. constant inst_text_color     = color black on gray
  17. constant inst_control_color  = color yellow
  18.  
  19. // progress bar colors
  20. constant bar_todo_color      = color black on gray
  21. constant bar_done_color      = color black on gray
  22.  
  23. // progress bar chars
  24. constant bar_todo_char       = '░'
  25. constant bar_done_char       = '▒'
  26.  
  27.  
  28. variable compdisplay, lastfile
  29.  
  30. titleprefix = arg 4
  31.  
  32. // message strings
  33. title     = titleprefix + "Installation"
  34. cancelmsg = titleprefix + "Installation canceled"
  35. failmsg   = titleprefix + "Installation failed"
  36. source_path = onname (getpath (getbootpath))
  37.  
  38. // for progress bar
  39. width = getvidcols
  40.  
  41. // create progress bar
  42. bar = createwindow
  43. setwinobj
  44. setcolor text_color bar_todo_color
  45. sizewindow 0 (getvidrows)-1 0 0 "rd"
  46.  
  47. private function resetbar
  48.   oldwin = gotowindow bar
  49.   writestr '':width:bar_todo_char bar_todo_color 1 1
  50.   gotowindow oldwin
  51. end
  52.  
  53. resetbar
  54.  
  55. // create status window
  56. createwindow
  57. setwinobj
  58. setframe ">b"
  59. setcolor  border_color   inst_border_color
  60. setcolor  text_color     inst_text_color
  61. setcolor  control_color  inst_control_color
  62. settitle "Aurora v" + getversion + ' ' + title
  63. setwinctrl '≡'
  64. sizewindow 1 1 -1 -2 "rd"
  65. setborder "1i"
  66. display
  67.  
  68. // get the install path
  69. install_path = onname (ask "Enter installation path:" ''
  70.                        source_path title 'd')
  71. if not install_path then
  72.   msgbox cancelmsg title
  73.   destroywindow
  74.   destroywindow
  75.   return
  76. end
  77.  
  78. // add backslash if not present
  79. if install_path [0] <> "\\" then
  80.   install_path = install_path + "\\"
  81. end
  82.  
  83. writestr "Installation path is " + install_path
  84.  
  85. // check if the install path exists
  86. if directory? install_path then
  87.   if (okbox  "Path " + install_path +
  88.              " already exists, install over it?" title) <> "Ok" then
  89.     msgbox cancelmsg title
  90.     destroywindow
  91.     destroywindow
  92.     return
  93.   end
  94.  
  95. // ..if not, then create it
  96. else
  97.   if (okbox "Path " + install_path +
  98.             " is not found, create it?" title) <> "Ok" then
  99.     msgbox cancelmsg title
  100.     destroywindow
  101.     destroywindow
  102.     return
  103.   else
  104.     if not createdir install_path then
  105.       msgbox "Can't create path " + install_path + " - " + failmsg  title
  106.       destroywindow
  107.       destroywindow
  108.       return
  109.     end
  110.   end
  111.   install_path = getpath (qualify install_path)
  112. end
  113.  
  114.  
  115. // create the style menu
  116. menu "mstyle"
  117.   item " &Aurora"                 "AU"
  118.   item " Aurora/&CUA/Windows"     "CU"
  119.   item " &Brief"                  "BR"
  120.   item " &MultiEdit"              "ME"
  121.   item " &QEdit/TSE"              "QE"
  122.   item " Word&Perfect"            "WP"
  123.   item " &WordStar/Borland IDE"   "WS"
  124. end
  125.  
  126. // get the editor style
  127. style = popup "mstyle" "Which editor style would you like to use?"
  128. destroybuf "mstyle"
  129. if not style then
  130.   msgbox cancelmsg title
  131.   destroywindow
  132.   destroywindow
  133.   return
  134. end
  135.  
  136. writeline
  137. writestr "Editor style is: " + style
  138. display
  139.  
  140. // create the color palette menu
  141. menu "colors"
  142.   item " &Blue and green"   "blugreen"
  143.   item " &Fluorescent"      "fluoresc"
  144.   item " &Green charcoal"   "greench"
  145.   item " &Red and blue"     "redblue"
  146.   item " &Wimbledon"        "wimbledn"
  147. end
  148.  
  149. // get the color palette to use
  150. palette = popup "colors" "Select a color palette to install" 37
  151. destroybuf "colors"
  152. if not palette then
  153.   msgbox cancelmsg title
  154.   destroywindow
  155.   destroywindow
  156.   return
  157. end
  158.  
  159. writeline
  160. writestr "Editor color palette is: " + palette
  161. display
  162.  
  163. // display compiling message only for a.x compilation
  164. event <compiling> (filename line)
  165.   if compdisplay and filename <> lastfile then
  166.     writeline
  167.     writestr "Compiling " + (onname filename) + "..."
  168.     display
  169.     lastfile = filename
  170.   end
  171. end
  172.  
  173. // disable <loading> event for this macro
  174. event <loading> end
  175.  
  176. // load installation file list
  177. listfile = arg 3
  178. if not listfile then
  179.   listfile = "install.dat"
  180. end
  181. listbuf = loadbuf (bootpath listfile)
  182. if not listbuf then
  183.   msgbox listfile + " not found." title
  184.   destroywindow
  185.   destroywindow
  186.   return
  187. end
  188.  
  189. lines = getlines
  190.  
  191. // check for same-path installation
  192. same_path = source_path == install_path
  193.  
  194. // copy files
  195. repeat
  196.   file = gettext
  197.   if file then
  198.     posblank = pos ' ' file
  199.     file = onname (file [1..(if? posblank posblank - 1 TO_END)])
  200.     if file [0] == '\\' then
  201.       if file == '\\' then
  202.         path = if? same_path '' install_path
  203.       else
  204.         path = file
  205.         createdir install_path + path
  206.       end
  207.     elseif path or file == "tran.aml" then
  208.       source = qualify file source_path
  209.       if path == install_path then
  210.         dest = qualify file install_path
  211.       else
  212.         if not locatefile source then
  213.           source = qualify file source_path + path
  214.         end
  215.         dest = qualify file install_path + path
  216.       end
  217.  
  218.       writeline
  219.       writestr "Copying " + source + " to " + dest + "..."
  220.       display
  221.  
  222.       if source <> dest then
  223.         if copyfile source dest then
  224.           if same_path then
  225.             deletefile source
  226.           end
  227.         else
  228.           // error copying non-optional files
  229.           if not icompare file "startup.aml" "user.aml" then
  230.             msgbox "Failed copying " + dest + ", " + failmsg  title
  231.             destroybuf listbuf
  232.             destroywindow
  233.             destroywindow
  234.             return
  235.           end
  236.         end
  237.       end
  238.  
  239.       // compile external macro source
  240.       if (icompare path "cfg\\" "macro\\" "syn\\") or
  241.          (locase file) == "tran.aml" then
  242.         // compile only .aml files (skip examples)
  243.         if (locase file) <> "example.aml" and
  244.            (locase (getext file)) == ".aml" then
  245.           writeline
  246.           writestr "Compiling " + dest + "..."
  247.           display
  248.           error = compilemacro dest dest [1 : length dest - 3] + 'x'
  249.           if error then
  250.             msgbox "Error (" + error + ") compiling macro " + dest
  251.           end
  252.         end
  253.       end
  254.     end
  255.   end
  256.  
  257.   // progress bar
  258.   variable lastx
  259.   x = ((getrow * width) / lines)
  260.   if lastx < x then
  261.     oldwin = gotowindow bar
  262.     writestr '':x:bar_done_char bar_done_color 1 1
  263.     gotowindow oldwin
  264.     lastx = x
  265.   end
  266.  
  267. until not down
  268.  
  269. // destroy the file list buffer
  270. destroybuf listbuf
  271.  
  272. // routine to copy style/palette files to the main install path
  273. private function copys (src_path sfile dfile)
  274.   source = onname (qualify sfile + ".aml" src_path)
  275.   dest = onname (qualify dfile + ".aml" install_path)
  276.   writeline
  277.   writestr "Copying " + source + " to " + dest
  278.   display
  279.   // make a backup copy
  280.   copyfile dest (qualify dfile + ".old" install_path)
  281.   if not copyfile source dest then
  282.     // error copying files
  283.     msgbox "Failed copying " + dest + ", " + failmsg  title
  284.     destroywindow
  285.     destroywindow
  286.     return 1
  287.   end
  288.   //return
  289. end
  290.  
  291. style_path = install_path + "style\\"
  292.  
  293. // copy keyboard style file
  294. if copys style_path style + "kbd" "kbd" then
  295.   return
  296. end
  297.  
  298. // copy menu style file
  299. if copys style_path style + "menu" "menu" then
  300.   return
  301. end
  302.  
  303. // copy color palette file
  304. if copys install_path + "palette\\"  palette "color" then
  305.   return
  306. end
  307.  
  308. writeline
  309. writestr "Recompiling the Editor..."
  310. display
  311.  
  312. compdisplay = TRUE
  313.  
  314. // recompile the editor
  315. save_boot = getbootpath
  316. setbootpath install_path
  317. error = regen
  318. setbootpath save_boot
  319.  
  320. // reset progress bar
  321. resetbar
  322.  
  323. if error then
  324.   msgbox "Compilation failed, " + failmsg  title
  325.   destroywindow
  326.   destroywindow
  327.   return
  328. else
  329.   writeline
  330.   writestr "*** End of Installation *** "
  331.